package cn.edu.shiep.action;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import cn.edu.shiep.model.User;
import cn.edu.shiep.service.UserService;

@Namespace("/userAction")
@Controller
public class UserAction extends BaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 7682764460662385172L;
	private final Logger log = Logger.getLogger(this.getClass());
	
	@Autowired
	private UserService userService;
	private List<User> userList = new ArrayList<User>();
//	private PageInfo pageInfo = new PageInfo();
	
	@Action(value="queryUserList",results={@Result(name=SUCCESS,location="/index.html")})
	public String queryUserList() {
		try {
			setUserList(userService.getAll());
			log.info("getAll() success!");
			return SUCCESS;
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			return ERROR;
		}
	}
	
	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}

}
